import moment from 'moment'
/* 
* 隐藏手机号中间四位
 */
export const hidePhoneFourRank = phone => {
  if (!phone || phone === '--') return ''
  return phone.substring(0,3) + '****' + phone.substring(7, phone.length)
}

/**
 * 格式化日期
 */
export const formatTime = (value,formatStr = 'YYYY-MM-DD HH:mm:ss',str = '') => {
  if (!value || value === '--') {
    return str ? str : ''
  }
  return moment(value).format(formatStr)
}

/*
* 数字增加千分符
* @param {Number} num
* fe:  request: 1234567     response: 1,234,567
*/
export function formatMoney (num) {
  return !num ? 0 : (num + '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
}
